package cn.edu.zafu.bigdata.bd121.studentdb.cli;


import cn.edu.zafu.bigdata.bd121.studentdb.command.BaseCommand;
import cn.edu.zafu.bigdata.bd121.studentdb.constant.DataBaseConst;
import cn.edu.zafu.bigdata.bd121.studentdb.constant.StudentInfoConst;
import cn.edu.zafu.bigdata.bd121.studentdb.entity.StudentPO;
import cn.hutool.json.JSONUtil;

import java.io.File;
import java.nio.charset.StandardCharsets;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.List;
import java.util.Scanner;

/**
 * 管理系统CLI入口
 *
 * @author 202211090121
 */
public class CliMain {

    public static Connection connection;

    public static Scanner scanner = new Scanner(System.in);

    static {
        try {
            connection = DriverManager.getConnection("jdbc:mysql://" + DataBaseConst.HOST + ":" + DataBaseConst.PORT + "/" + DataBaseConst.DATABASE, DataBaseConst.USERNAME, DataBaseConst.PASSWORD);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }

    public static void main(String[] args) {
        String input;
        do {
            Menu.showMenu();
            input = scanner.nextLine();
            BaseCommand command = Menu.selectMenu(input);
            command.execute();
        } while (!"5".equals(input));
    }
}
